<template>
	<div id="StorageCellFuhe">
		<h1>您正在做的业务是：库存管理--安全库存配置管理--制定安全库存配置单复核</h1>
			
		<el-table
		  :data="cellAry"
		  style="width: 100%">
		  <el-table-column
		    prop="storeId"
		    label="配置单编号"
		    width="200">
		  </el-table-column>
		  <el-table-column
		    prop="productId"
		    label="产品编号"
		    width="200">
		  </el-table-column>
		  <el-table-column
		    prop="productName"
		    label="产品名称"
		    width="200">
		  </el-table-column>
			<el-table-column
			  prop="firstKindName"
			  label="I级分类"
			  width="200">
			</el-table-column>
			<el-table-column
			  prop="secondKindName"
			  label="II级分类"
			  width="200">
			</el-table-column>
			<el-table-column
			  prop="thirdKindName"
			  label="III级分类"
			  width="200">
			</el-table-column>
			<el-table-column
			  prop="registerTime"
			  label="登记时间"
			  width="200">
			</el-table-column>
		  <!--操作列-->
		  <el-table-column label="操作">
		  <template slot-scope="scope">
		    <el-button
		      size="mini"
			  type="danger"
		      @click="handleFuhe(scope.$index, scope.row)">复核</el-button>
		  </template>
		</el-table-column>
		</el-table>
		<!---分页组件-->
		<el-pagination
		  @size-change="handleSizeChange"
		  @current-change="handleCurrentChange"
		  :current-page="currentPage"
		  :page-sizes="pageSizeList"
		  :page-size="pageSize"
		  layout="total, sizes, prev, pager, next, jumper"
		  :total="total">
		</el-pagination>
		
		<!-- 添加对话框 -->
			<el-dialog title="您正在做的业务是：库存管理--安全库存配置管理--制定安全库存配置单复核" :visible.sync="addFormVisible">
				  <input type="hidden" v-model="addForm.custId">
			  <el-form :model="form">
				  <el-form-item label="配置单编号" :label-width="formLabelWidth">
				    <el-input v-model="addForm.storeId" autocomplete="off"></el-input>
				  </el-form-item>
				  
			    <el-form-item label="产品名称" :label-width="formLabelWidth">
			      <el-input v-model="addForm.productName" autocomplete="off"></el-input>
			    </el-form-item>
				
			    <el-form-item label="产品编号" :label-width="formLabelWidth">
				     <el-input v-model="addForm.productId" autocomplete="off"></el-input>
			    </el-form-item>
				<el-form-item label="库存报警下限数：" :label-width="formLabelWidth">
				   <el-input v-model="addForm.minAmount" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="库存报警上限数：" :label-width="formLabelWidth">
				   <el-input v-model="addForm.maxAmount" autocomplete="off"></el-input>
				</el-form-item>
				
				<el-form-item label="复核人：" :label-width="formLabelWidth">
				  <el-input v-model="addForm.checker" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="复核时间：" :label-width="formLabelWidth">
				  <el-input v-model="addForm.checkerTime" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="最大存储量：" :label-width="formLabelWidth">
				  <el-input v-model="addForm.maxCapacityAmount" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="当前存储量：" :label-width="formLabelWidth">
				  <el-input v-model="addForm.amount" autocomplete="off"></el-input>
				</el-form-item>
				<el-form-item label="配置要求：" :label-width="formLabelWidth">
				  <el-input v-model="addForm.config" autocomplete="off"></el-input>
				</el-form-item>
			  </el-form>
			  <div slot="footer" class="dialog-footer">
			    <el-button @click="addFormVisible = false">取 消</el-button>
			    <el-button type="primary" @click="saveUpd">通过</el-button>
			  </div>
			</el-dialog>
	</div>
</template>

<script>
	import axios from "axios";
	export default{
		name:'StorageCellFuhe',
		data() {
			return{
				cellAry:{},
				// 当前页号
				currentPage: 1,
				// 当前页大小
				pageSize: 5,
				// 总记录数
				total: 13,
				// 页大小列表
				pageSizeList: [2, 5, 10, 20],
				formLabelWidth:'120px',
				addForm:{},
				addFormVisible:false,
			}
		},
		methods:{	
			async saveUpd(){
				//用es6的解构函数
				const{data:res}=await this.$http.post
				('/design/storage/UpdateById',this.addForm)
				console.log(res);
				if(res == 'ok') {
				  // 隐藏
				  this.addFormVisible = false
				  // 消息提示
				  this.$message('修改成功')
				  // 刷新表格
				  this.StroageCellPageFuhe()
				}
			},
			handleFuhe(index, row) {
				 // this.addFormVisible=true
				 // // 用es6的解构函数
				 // const id=row.id
				 //   const {data: res} = await this.$http.post
				 //   (`/design/storage/listById?id=${id}`)
				 // console.log(res);
				 //   this.addForm = res.data
				   
				   this.addFormVisible=true
				      const id = row.id
				      axios.post(`http://localhost:8989/design/storage/listById?id=${id}`).then((res)=>{
				   	   console.log(2000,res);
				      				// 获取当页数据集合，绑定到表格
				      				this.addForm = res.data
				      })
			  },
			  
			// 分页查询安全库存信息
			async StroageCellPageFuhe() {
			  // 用es6的解构函数
			  const {data: res} = await this.$http.post
			  (`/design/storage/fuheCell/${this.currentPage}/${this.pageSize}`)
			console.log(res);
			  this.cellAry = res.rows
			  this.total = res.total
			},
			handleSizeChange(val) {
			    this.pageSize = val
			    this.StroageCellPageFuhe()
			},
			// 页号改变
			handleCurrentChange(val) {
			  this.currentPage = val
			  // 重新查询
			  this.StroageCellPageFuhe()
			},
			
		},
		created() {
			this.StroageCellPageFuhe()
		}
	}
	
</script>

<style>
</style>